package com.zzk.lanouhn.myapplication1.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.squareup.picasso.Picasso;
import com.zzk.lanouhn.myapplication1.R;
import com.zzk.lanouhn.myapplication1.modles.FindDetailsXiaotuLikeModle;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lanouhn on 16/9/12.
 */
public class FindXiaotuLikeAdapter extends RecyclerView.Adapter<FindXiaotuLikeAdapter.MyHolder> {
    private Context context;
    private List<FindDetailsXiaotuLikeModle> modles = new ArrayList<>();

    public FindXiaotuLikeAdapter(Context context, List<FindDetailsXiaotuLikeModle> modles) {
        this.context = context;
        this.modles = modles;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view;
        view= LayoutInflater.from(context).inflate(R.layout.item_find_xiaotu_like, null);
        MyHolder holder = new MyHolder(view);
        return holder;

    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        if (modles.size() > 0) {
            holder.iv.setVisibility(View.VISIBLE);
            holder.ll.setVisibility(View.GONE);
            Picasso.with(context).load(modles.get(position).getPhoto_url()).into(holder.iv);
        } else {
            //没实现
            holder.iv.setVisibility(View.GONE);
            holder.ll.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public int getItemCount() {
        return modles.size();
    }

    public class MyHolder extends RecyclerView.ViewHolder {

        private ImageView iv;
        private LinearLayout ll;

        public MyHolder(View itemView) {
            super(itemView);
            iv = (ImageView) itemView.findViewById(R.id.item_find_details_xiaotu_like);
            ll = (LinearLayout) itemView.findViewById(R.id.item_find_details_xiaotu_ll);
        }
    }

}
